<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Nabu-asr: sigproc.py File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Nabu-asr
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_5a19dd24bd3679bb79d0ed8fbf6eb6c5.html">nabu</a></li><li class="navelem"><a class="el" href="dir_38a0e828cfd915bf1a57174729a2f8cd.html">processing</a></li><li class="navelem"><a class="el" href="dir_e13f2eda408f5edf365c238eb07cf74b.html">processors</a></li><li class="navelem"><a class="el" href="dir_9dd70351104cb74361e0a1ecfe3b7415.html">feature_computers</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">sigproc.py File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>contains the signal processing functionality  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a3b34b7d7067c1c025d1fdc8a049cef24"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#a3b34b7d7067c1c025d1fdc8a049cef24">nabu.processing.processors.feature_computers.sigproc.framesig</a> (sig, frame_len, frame_step, winfunc=lambda x:numpy.ones((x,)))</td></tr>
<tr class="memdesc:a3b34b7d7067c1c025d1fdc8a049cef24"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frame a signal into overlapping frames.  <a href="sigproc_8py.html#a3b34b7d7067c1c025d1fdc8a049cef24">More...</a><br /></td></tr>
<tr class="separator:a3b34b7d7067c1c025d1fdc8a049cef24"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20b903a0d7065c999d249590943deb43"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#a20b903a0d7065c999d249590943deb43">nabu.processing.processors.feature_computers.sigproc.deframesig</a> (frames, siglen, frame_len, frame_step, winfunc=lambda x:numpy.ones((x,)))</td></tr>
<tr class="memdesc:a20b903a0d7065c999d249590943deb43"><td class="mdescLeft">&#160;</td><td class="mdescRight">Does overlap-add procedure to undo the action of framesig.  <a href="sigproc_8py.html#a20b903a0d7065c999d249590943deb43">More...</a><br /></td></tr>
<tr class="separator:a20b903a0d7065c999d249590943deb43"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4fba71fc47e9cb1dc0f5427d6a7612af"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#a4fba71fc47e9cb1dc0f5427d6a7612af">nabu.processing.processors.feature_computers.sigproc.magspec</a> (frames, nfft)</td></tr>
<tr class="memdesc:a4fba71fc47e9cb1dc0f5427d6a7612af"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the magnitude spectrum of each frame in frames.  <a href="sigproc_8py.html#a4fba71fc47e9cb1dc0f5427d6a7612af">More...</a><br /></td></tr>
<tr class="separator:a4fba71fc47e9cb1dc0f5427d6a7612af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa723b5765e6537fdc8c85eeac3b105ef"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#aa723b5765e6537fdc8c85eeac3b105ef">nabu.processing.processors.feature_computers.sigproc.powspec</a> (frames, nfft)</td></tr>
<tr class="memdesc:aa723b5765e6537fdc8c85eeac3b105ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the power spectrum of each frame in frames.  <a href="sigproc_8py.html#aa723b5765e6537fdc8c85eeac3b105ef">More...</a><br /></td></tr>
<tr class="separator:aa723b5765e6537fdc8c85eeac3b105ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0c89f348bedbe8eb7c9c48fc13be1ef1"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#a0c89f348bedbe8eb7c9c48fc13be1ef1">nabu.processing.processors.feature_computers.sigproc.logpowspec</a> (frames, nfft, norm=1)</td></tr>
<tr class="memdesc:a0c89f348bedbe8eb7c9c48fc13be1ef1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the log power spectrum of each frame in frames.  <a href="sigproc_8py.html#a0c89f348bedbe8eb7c9c48fc13be1ef1">More...</a><br /></td></tr>
<tr class="separator:a0c89f348bedbe8eb7c9c48fc13be1ef1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d2e2e6f8018a3cc47489bb6e7ca2853"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#a0d2e2e6f8018a3cc47489bb6e7ca2853">nabu.processing.processors.feature_computers.sigproc.preemphasis</a> (signal, coeff=0.95)</td></tr>
<tr class="memdesc:a0d2e2e6f8018a3cc47489bb6e7ca2853"><td class="mdescLeft">&#160;</td><td class="mdescRight">perform preemphasis on the input signal.  <a href="sigproc_8py.html#a0d2e2e6f8018a3cc47489bb6e7ca2853">More...</a><br /></td></tr>
<tr class="separator:a0d2e2e6f8018a3cc47489bb6e7ca2853"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac3ebf758ea515730ef0438bdd51cccfb"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sigproc_8py.html#ac3ebf758ea515730ef0438bdd51cccfb">nabu.processing.processors.feature_computers.sigproc.snip</a> (sig, rate, winlen, winstep)</td></tr>
<tr class="memdesc:ac3ebf758ea515730ef0438bdd51cccfb"><td class="mdescLeft">&#160;</td><td class="mdescRight">snip the edges of the utterance to fit the sliding window  <a href="sigproc_8py.html#ac3ebf758ea515730ef0438bdd51cccfb">More...</a><br /></td></tr>
<tr class="separator:ac3ebf758ea515730ef0438bdd51cccfb"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>contains the signal processing functionality </p>
<p>The MIT License (MIT)</p>
<p>Copyright (c) 2013 James Lyons</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<p>This file includes routines for basic signal processing including framing and computing power spectra. </p><dl class="section author"><dt>Author</dt><dd>: James Lyons 2012 </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="file_a20b903a0d7065c999d249590943deb43"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a20b903a0d7065c999d249590943deb43">&sect;&nbsp;</a></span>deframesig()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.deframesig </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frames</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>siglen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frame_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frame_step</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>winfunc</em> = <code>lambda&#160;x:&#160;numpy.ones((x,&#160;))</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Does overlap-add procedure to undo the action of framesig. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">frames</td><td>array of frames. </td></tr>
    <tr><td class="paramname">siglen</td><td>length of the desired signal, use 0 if unknown. Output will be truncated to siglen samples. </td></tr>
    <tr><td class="paramname">frame_len</td><td>length of each frame measured in samples. </td></tr>
    <tr><td class="paramname">frame_step</td><td>number of samples after the start of the previous frame that the next frame should begin. </td></tr>
    <tr><td class="paramname">winfunc</td><td>the analysis window to apply to each frame. By default no window is applied.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a 1-D signal. </dd></dl>

</div>
</div>
<a id="file_a3b34b7d7067c1c025d1fdc8a049cef24"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a3b34b7d7067c1c025d1fdc8a049cef24">&sect;&nbsp;</a></span>framesig()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.framesig </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frame_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frame_step</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>winfunc</em> = <code>lambda&#160;x:&#160;numpy.ones((x,&#160;))</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Frame a signal into overlapping frames. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sig</td><td>the audio signal to frame. </td></tr>
    <tr><td class="paramname">frame_len</td><td>length of each frame measured in samples. </td></tr>
    <tr><td class="paramname">frame_step</td><td>number of samples after the start of the previous frame that the next frame should begin. </td></tr>
    <tr><td class="paramname">winfunc</td><td>the analysis window to apply to each frame. By default no window is applied.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>an array of frames. Size is NUMFRAMES by frame_len. </dd></dl>

</div>
</div>
<a id="file_a0c89f348bedbe8eb7c9c48fc13be1ef1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a0c89f348bedbe8eb7c9c48fc13be1ef1">&sect;&nbsp;</a></span>logpowspec()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.logpowspec </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frames</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>nfft</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>norm</em> = <code>1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Compute the log power spectrum of each frame in frames. </p>
<p>If frames is an NxD matrix, output will be NxNFFT.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">frames</td><td>the array of frames. Each row is a frame. </td></tr>
    <tr><td class="paramname">nfft</td><td>the FFT length to use. If NFFT &gt; frame_len, the frames are zero-padded. </td></tr>
    <tr><td class="paramname">norm</td><td>If norm=1, the log power spectrum is normalised so that the max value (across all frames) is 1.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If frames is an NxD matrix, output will be NxNFFT. Each row will be the log power spectrum of the corresponding frame. </dd></dl>

</div>
</div>
<a id="file_a4fba71fc47e9cb1dc0f5427d6a7612af"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a4fba71fc47e9cb1dc0f5427d6a7612af">&sect;&nbsp;</a></span>magspec()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.magspec </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frames</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>nfft</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Compute the magnitude spectrum of each frame in frames. </p>
<p>If frames is an NxD matrix, output will be NxNFFT.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">frames</td><td>the array of frames. Each row is a frame. </td></tr>
    <tr><td class="paramname">nfft</td><td>the FFT length to use. If NFFT &gt; frame_len, the frames are zero-padded.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If frames is an NxD matrix, output will be NxNFFT. Each row will be the magnitude spectrum of the corresponding frame. </dd></dl>

</div>
</div>
<a id="file_aa723b5765e6537fdc8c85eeac3b105ef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_aa723b5765e6537fdc8c85eeac3b105ef">&sect;&nbsp;</a></span>powspec()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.powspec </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>frames</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>nfft</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Compute the power spectrum of each frame in frames. </p>
<p>If frames is an NxD matrix, output will be NxNFFT.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">frames</td><td>the array of frames. Each row is a frame. </td></tr>
    <tr><td class="paramname">nfft</td><td>the FFT length to use. If NFFT &gt; frame_len, the frames are zero-padded.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>If frames is an NxD matrix, output will be NxNFFT. Each row will be the power spectrum of the corresponding frame. </dd></dl>

</div>
</div>
<a id="file_a0d2e2e6f8018a3cc47489bb6e7ca2853"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a0d2e2e6f8018a3cc47489bb6e7ca2853">&sect;&nbsp;</a></span>preemphasis()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.preemphasis </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>signal</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>coeff</em> = <code>0.95</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>perform preemphasis on the input signal. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">signal</td><td>The signal to filter. </td></tr>
    <tr><td class="paramname">coeff</td><td>The preemphasis coefficient. 0 is no filter, default is 0.95.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the filtered signal. </dd></dl>

</div>
</div>
<a id="file_ac3ebf758ea515730ef0438bdd51cccfb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_ac3ebf758ea515730ef0438bdd51cccfb">&sect;&nbsp;</a></span>snip()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.processing.processors.feature_computers.sigproc.snip </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>sig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>rate</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>winlen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>winstep</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>snip the edges of the utterance to fit the sliding window </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sig</td><td>audio signal </td></tr>
    <tr><td class="paramname">rate</td><td>sampling rate </td></tr>
    <tr><td class="paramname">winlen</td><td>length of the sliding window [s] </td></tr>
    <tr><td class="paramname">winstep</td><td>stepsize of the sliding window [s]</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the snipped signal </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>
